﻿<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head><link rel="stylesheet" href="${ctx}/common/common.css">
<meta charset="utf-8">
<title>新建工艺</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet"
	href="${ctx}/common/plugins/layuiadmin/layui/css/layui.css" media="all">
	<link rel="stylesheet"
	href="${ctx}/common/plugins/layuiadmin/layui/css/modules/layer/default/layer.css" media="all">
<link rel="stylesheet"
	href="${ctx}/common/plugins/layuiadmin/style/admin.css" media="all">
	<script src="${ctx}/common/plugins/layuiadmin/layui/layui.js"></script>
    
<script src="${ctx}/common/plugins/layuiadmin/layui/lay/modules/layer.js"></script>

<%-- <script src="${ctx}/common/plugins/publicJs/publicJs.js"></script> --%>
<style>
.layui-table-header {
	width: 100%;
}

.layui-table-header th {
	width: 20%;
	text-align: center;
}

.layui-products {
	border-bottom: 2px solid #e7e7e7;
	/*border-top: 2px solid #e7e7e7;*/
	margin: 10px 0px;
	padding: 5px 0px;
}

.layui-products_li {
	margin-left: 50px;
	border-bottom: 1px dashed #e7e7e7;
}

.layui-products_li:first-child {
	border: none;
}

.layui-col-md4 img {
	margin-right: 5px;
	width: 22px;
	height: 22px;
}

.layui-col-md4 img {
	margin-right: 5px;
	width: 22px;
	height: 22px;
}
</style>
</head>
<body>
	<!--主体内容层-->
	<form class="layui-form" action="${ctx}/process/processAddSave">
	<input type="hidden" id="oldcode" value="${proess.code }">
	<div class="layui-fluid">
		<div class="layui-row rowtop" style="margin-top: 20px;">
			<!--输入框内容盒子-->
			<!--输入框-->
			<div class="layui-form-item layui-col-md6">
				<label class="layui-form-label">工艺代码<span style="color: red">*</span></label>
				
				<div class="layui-input-block">
					<input type="hidden" id="id" name="id" class="layui-input" value="${proess.id }">
					<input type="text" id="code" name="code" value="${proess.code }"
						lay-verify="required|verifyCode" placeholder="工艺代码" autocomplete="off"
						class="layui-input">
				</div>
			</div>
			<div class="layui-form-item layui-col-md6">
				<label class="layui-form-label">工艺名称<span style="color: red">*</span></label>
				<div class="layui-input-block">
					<input type="text" id="name" name="name" value="${proess.name }"
						lay-verify="required" placeholder="工艺名称" autocomplete="off"
						class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
	                <button type="button" id="rollback" class="layui-btn layui-btn-primary">返回</button>
	                <button class="layui-btn" id="formBtn" lay-submit lay-filter="formDemo">提交</button>
	            </div>
            </div>
		</div>
	</div>
	</form>
	
	<script type="text/javascript">
		document.getElementById("rollback").addEventListener("click",function(){
	        window.history.back();
	    });
		
		layui.use('form', function() {
			var form = layui.form;
			var $ = layui.$;
			form.verify({
				verifyCode : function(value, item) {
					if(!/^[a-zA-Z\d]+$/.test(value)){
						return '工艺代码只能输入数字和英文';
					}
					console.log($("#oldcode").val());
	                 if($("#oldcode").val() != value){
	 	                var isSubmit=true;
	 	                $.ajax({
	 	                    url: "${ctx}/process/checkCode",
	 	                    data: {checkCode:value}, //请求的附加参数，用json对象
	 	                    method: 'POST',
	 	                    async:false,
	 	                    success: function (data) {
	 	                        if (data == '0') {
	 	                            isSubmit=false;
	 	                        }
	 	                    }
	 	                });
	 	                if(isSubmit==false){
	 	                    return "工艺代码已存在";
	 	                }
	                 }
				}
			});
		})
		
		layui.use('form', function(){
	        var form = layui.form;
	        /* 监听提交 */
	        form.on('submit(formDemo)', function(data){
	        	layer.load(1, {
	       	    	shade: [0.1,'#fff'] //0.1透明度的白色背景
	       		});
	            $("#formBtn").attr("disabled",true);
	        });
	    });
	</script>
</body>
</html>







